import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'JavaScript',
      redirect: '/loop',
      children: [
        {
          path: '/loop',
          name: '遍历方法',
          component: () => import('../views/loop.vue'),
        },{
          path: '/fun',
          name: '函数',
          component: () => import('../views/fun.vue'),
        },{
          path: '/destructuring',
          name: '解构',
          component: () => import('../views/destructuring.vue'),
        }
      ]
    },
    {
      path: '/network',
      name: '网络请求',
      redirect: '/then',
      children: [
        {
          path: '/then',
          name: 'Promise.then()',
          component: () => import('../views/network/then.vue'),
        },{
          path: '/async',
          name: 'async/await',
          component: () => import('../views/network/async.vue'),
        }
      ]
    },
    {
      path: '/Json',
      name: 'Json',
      children: [
        {
          path: '/Json',
          name: 'Json',
          component: () => import('../views/Json.vue'),
        }
      ]
    },
    {
      path: '/dataStructure',
      name: '数据结构修改方法',
      children: [
        {
          path: '/arrayToObj',
          name: '数组转数组对象结构',
          component: () => import('../views/dataStructure/arrayToObj.vue'),
        },{
          path: '/seekArrObj',
          name: '查找匹配修改数组对象',
          component: () => import('../views/dataStructure/seekArrObj.vue'),
        },{
          path: '/addAttribute',
          name: '数组对象添加新属性',
          component: () => import('../views/dataStructure/addAttribute.vue'),
        },{
          path: '/attributeNameChange',
          name: '修改数组对象的属性名',
          component: () => import('../views/dataStructure/attributeNameChange.vue'),
        },{
          path: '/strSplitArr',
          name: '字符串分割成数组',
          component: () => import('../views/dataStructure/strSplitArr.vue'),
        },{
          path: '/arrJoinStr',
          name: '数组合并成字符串',
          component: () => import('../views/dataStructure/arrJoinStr.vue'),
        },{
          path: '/strToGeoJson',
          name: '字符串转GeoJson',
          component: () => import('../views/dataStructure/strToGeoJson.vue'),
        },{
          path: '/moveAndDelete',
          name: '移动数组元素并删除原位置的元素',
          component: () => import('../views/dataStructure/moveAndDelete.vue'),
        },{
          path: '/editObjNestingVal',
          name: '修改对象嵌套对象的某一个值',
          component: () => import('../views/dataStructure/editObjNestingVal.vue'),
        },{
          path: '/cutArrayMultidimensionalArrays',
          name: '数组切割成多维数组',
          component: () => import('../views/dataStructure/cutArrayMultidimensionalArrays.vue'),
        },
      ]
    },
    {
      path: '/RegExp',
      name: '正则表达式',
      children: [
        {
          path: '/RegExpSyntax',
          name: '语法表',
          component: () => import('../views/RegExp/RegExpSyntax.vue'),
        }
      ]
    }
  ]
})

export default router
